import { Badge, Input, InputNumber, message, Popconfirm, Space, TableColumnsType, Tag, Tooltip, Typography } from 'antd'
import type { ITableData } from './types'
import * as mathjs from 'mathjs'
export const useColumns = ({
  onViewLogs,
  verifyCost,
  canVertifyCost,
}: {
  onViewLogs: (tableData: ITableData) => void
  verifyCost: (tableData: ITableData) => void
  canVertifyCost: boolean
}): TableColumnsType<ITableData> => [
  {
    title: '年份',
    dataIndex: 'productYear',
    key: 'productYear',
    align: 'center',
    width: 120,
    render: (info) => {
      return info || '-'
    },
  },
  {
    title: '订单季节',
    dataIndex: 'seasonCode',
    key: 'seasonCode',
    align: 'center',
    width: 120,
    render: (info) => {
      return info || '-'
    },
  },
  {
    title: '大类',
    dataIndex: 'largeClassName',
    key: 'largeClassName',
    align: 'center',
    width: 120,
    render: (info) => {
      return info || '-'
    },
  },
  {
    title: '渠道',
    dataIndex: 'channel',
    key: 'channel',
    align: 'center',
    width: 120,
    render: (info) => {
      return info == 1 ? '直营' : info == 2 ? '加盟' : '-'
    },
  },
  {
    title: '总成本额度',
    dataIndex: 'totalCostAmount',
    key: 'totalCostAmount',
    align: 'center',
    width: 140,
    render: (info) => {
      return info > 0 ? mathjs.divide(mathjs.bignumber(info), 10000).toString() + '万' : '-'
    },
  },
  {
    title: '已用成本额度',
    dataIndex: 'usedCostAmount',
    key: 'usedCostAmount',
    align: 'center',
    width: 140,
    render: (info) => {
      return info > 0 ? mathjs.divide(mathjs.bignumber(info), 10000).toString() + '万' : '-'
    },
  },
  {
    title: '可用成本额度',
    dataIndex: 'availableCostAmount',
    key: 'availableCostAmount',
    align: 'center',
    width: 140,
    render: (info) => {
      return info > 0 ? mathjs.divide(mathjs.bignumber(info), 10000).toString() + '万' : '-'
    },
  },
  {
    title: '待审核成本额度',
    dataIndex: 'auditCostAmount',
    key: 'auditCostAmount',
    align: 'center',
    width: 140,
    render: (info) => {
      return info > 0 ? mathjs.divide(mathjs.bignumber(info), 10000).toString() + '万' : '-'
    },
  },
  {
    title: '总吊牌额度',
    dataIndex: 'totalTagAmount',
    key: 'totalTagAmount',
    align: 'center',
    width: 140,
    render: (info) => {
      return info > 0 ? mathjs.divide(mathjs.bignumber(info), 10000).toString() + '万' : '-'
    },
  },
  {
    title: '已用吊牌额度',
    dataIndex: 'usedTagAmount',
    key: 'usedTagAmount',
    align: 'center',
    width: 140,
    render: (info) => {
      return info > 0 ? mathjs.divide(mathjs.bignumber(info), 10000).toString() + '万' : '-'
    },
  },
  {
    title: '可用吊牌额度',
    dataIndex: 'availableTagAmount',
    key: 'availableTagAmount',
    align: 'center',
    width: 140,
    render: (info) => {
      return info > 0 ? mathjs.divide(mathjs.bignumber(info), 10000).toString() + '万' : '-'
    },
  },
  {
    title: '待审核吊牌额度',
    dataIndex: 'auditTagAmount',
    key: 'auditTagAmount',
    align: 'center',
    width: 140,
    render: (info) => {
      return info > 0 ? mathjs.divide(mathjs.bignumber(info), 10000).toString() + '万' : '-'
    },
  },
  {
    title: '操作',
    dataIndex: 'factorySpuCode',
    key: 'factorySpuCode',
    align: 'center',
    width: 220,
    fixed: 'right',
    render: (_, rows) => {
      return (
        <Space size="large">
          {Number(rows?.auditCostAmount) > 0 && canVertifyCost && (
            <Typography.Link onClick={() => verifyCost(rows)}>审核额度</Typography.Link>
          )}
          <Typography.Link onClick={() => onViewLogs(rows)}>查看日志</Typography.Link>
        </Space>
      )
    },
  },
]
